package com.czl.module_service.fragment.purchase

import android.os.Bundle
import com.alibaba.android.arouter.facade.annotation.Route
import com.czl.base.base.BaseTabFragment
import com.czl.base.base.BaseTabViewModel
import com.czl.base.config.AppConstants
import com.czl.base.databinding.FragmentBaseTabBinding
import com.czl.base.event.LiveBusCenter
import com.czl.base.route.RouteCenter
import me.yokeyword.fragmentation.SupportFragment

@Route(path = AppConstants.Router.Service.F_SERVICE_PURCHASE_APPLY)
class PurchaseApplyFragment : BaseTabFragment<FragmentBaseTabBinding, BaseTabViewModel>() {

    override fun initViewObservable() {
        super.initViewObservable()
        LiveBusCenter.observeGoToTabEvent(this, {
            binding.viewPager.currentItem = 1
            LiveBusCenter.postAssetResultReturnEvent(1)
        })
    }

    override fun fragments(): List<SupportFragment> {
        return arrayListOf(
            RouteCenter.navigate(AppConstants.Router.Service.F_SERVICE_PURCHASE_APPLY_ADD, Bundle().apply {

            }) as SupportFragment,

            RouteCenter.navigate(AppConstants.Router.Service.F_SERVICE_PURCHASE_MY_APPLY, Bundle().apply {
                putSerializable(AppConstants.BundleKey.USAGE_TAB_INDEX, 1)
            }) as SupportFragment,

            RouteCenter.navigate(AppConstants.Router.Service.F_SERVICE_PURCHASE_MY_APPLY, Bundle().apply {
                putSerializable(AppConstants.BundleKey.USAGE_TAB_INDEX, 2)
            }) as SupportFragment
        )
    }

    override fun initData() {
        super.initData()
        viewModel.tabData.set("采购申请, 我的申请, 采购审批")
        viewModel.tvTitle.set("采购申请")
    }

    override fun useBaseLayout(): Boolean {
        return true
    }
}